import UIComponent = laya.ui.UIComponent;
import VMComponent from "./VMComponent";
import { IComponentDirective } from "../../ADCore/Interfaces/IMVVM";
import { CompileUtil } from "../../ADCore/MVVM/CompileUtil";

/**
 * LAYAUI 解析类
 */
export default class LayaCompileUtil implements IComponentDirective {
  getChildNodes(el: any) {
    return el._children;
  }
  addInputListener(el: any, func: any) { 
    el.on("input", el, function (e) { 
      let newVal = e.text;
      CompileUtil.$elCurrent = e;
      func(newVal);
    });
  }
  addEventListener(el: any, eventType: string, func: any, once: number) {
    el.on(eventType, el, func);
  }

  isComponent(el: any) {
    
    return (el as UIComponent) !== undefined;
  }
  getComponent(el: any) {
    return el.getComponent(VMComponent);
  }
}
